package IndusmecaSI.Indusmeca_Controller
{
	public class Controller_MenuAccueil
	{
		
		public function Controller_MenuAccueil()
		{
		}
		
		
		protected function afficheBtnPrincipal(event:ResultEvent):void
		{
			
			for( var i:int = 0; i<getListbuttonResult.lastResult.length; i++){
				var tempButton:Button = new Button();
				tempButton.id = getListbuttonResult.lastResult[i].id_button;
				tempButton.label = getListbuttonResult.lastResult[i].label_flex;
				tempButton.percentWidth = 80;
				tempButton.visible = true;	
				tempButton.uid = getListbuttonResult.lastResult[i].groupName;
				tempButton.name = getListbuttonResult.lastResult[i].stateName;
				tempButton.addEventListener(MouseEvent.CLICK,clickBtnPrincipal);
				//tempButton.toolTip = (getListbuttonResult.lastResult[i].id_menuTypeEnfant);
				groupMenu.addElement(tempButton as IVisualElement)
				var newGroup:VGroup = new VGroup();
				newGroup.id = getListbuttonResult.lastResult[i].groupName;
				newGroup.horizontalAlign = "right";
				newGroup.visible = false;
				newGroup.percentWidth = 80;
				newGroup.includeInLayout = false;		
				groupMenu.addElement(newGroup as IVisualElement);
				var id_menu_enfant:int = parseInt(getListbuttonResult.lastResult[i].id_menuTypeEnfant);
				if(tempButton.label!="Quitter"){
					getListBtnSecondaire(groupMenu.getElementIndex(newGroup),id_menu_enfant);	
				}
			}
		}
		
		protected function afficheBtnSecondaire(event:ResultEvent):void
		{
			for( var j:int = 0; j<event.result.length; j++){	
				var tempButton:Button = new Button();
				tempButton.id = event.result[j].id_button;					
				tempButton.label = event.result[j].label_flex;		
				tempButton.percentWidth = 80;
				tempButton.visible = true;	
				tempButton.uid = event.result[j].groupName;
				tempButton.name = event.result[j].stateName;
				tempButton.addEventListener(MouseEvent.CLICK,clickBtnSecondaire);
				var index:int = (ListButton)(event.result[j]).placeBtnDepart;
				groupMenu.getElementAt(index).visible = true;
				VGroup(groupMenu.getElementAt(index)).addElement(tempButton as IVisualElement);	
			}
		}
	}
}